import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FarmerVO, FarmerForm, FarmerQuery } from '@/api/farmer/farmer/types';

/**
 * 查询农户查询列表
 * @param query
 * @returns {*}
 */

export const listFarmer = (query?: FarmerQuery): AxiosPromise<FarmerVO[]> => {
  return request({
    url: '/farmer/farmer/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询农户查询详细
 * @param id
 */
export const getFarmer = (id: string | number): AxiosPromise<FarmerVO> => {
  return request({
    url: '/farmer/farmer/' + id,
    method: 'get'
  });
};

/**
 * 新增农户查询
 * @param data
 */
export const addFarmer = (data: FarmerForm) => {
  return request({
    url: '/farmer/farmer',
    method: 'post',
    data: data
  });
};

/**
 * 修改农户查询
 * @param data
 */
export const updateFarmer = (data: FarmerForm) => {
  return request({
    url: '/farmer/farmer',
    method: 'put',
    data: data
  });
};

/**
 * 删除农户查询
 * @param id
 */
export const delFarmer = (id: string | number | Array<string | number>) => {
  return request({
    url: '/farmer/farmer/' + id,
    method: 'delete'
  });
};
